module Mouse

  class Cursor
    attr_reader :img, :visible, :imgObj
    def initialize(img,visible)
      @img=img
      @visible=visible
      @imgObj=Gosu::Image.new($window,img,true)
      @forced=false
    end
    def toggleVisible
      if not @forced
        @visible=!@visible
      end
    end
    def forceVisible(visible=true)
      @forced=true
      @visible=visible
    end
    def unforceVisible
      @forced=false
    end
    def visible?
      return visible
    end
    def visible=(visible)
      if not @forced
        @visible=visible
      end
    end
    def draw
      if @visible
        @imgObj.draw($window.mouse_x,$window.mouse_y,ZOrder::Cursor)
      end
    end
    def to_s
      return "{[Cursor]::Img="+img+"}"
    end
  end
  
  class MouseDragEvent
    attr_reader :start_x, :start_y, :end_x, :end_y, :inprogress, :starting
    def initialize
      @start_x, @start_y = 0
      @end_x, @end_y = 0
      @inprogress = false
      @starting = false
    end
    def start
      @start_x, @start_y = $window.mouse_x, $window.mouse_y
      @starting = true
    end
    def confirmStart
      @starting = false
      @inprogress = true
    end
    def end
      @end_x, @end_y = $window.mouse_x, $window.mouse_y
      @inprogress = false
    end
    def terminate
      @inprogress, @starting = false
    end
  end
  
end #module Mouse

include Mouse